package com.js.purs.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.js.purs.domain.PurEvaFile;
import com.js.purs.service.IPurEvaFileService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 招标附件Controller
 * 
 * @author lzq
 * @date 20240708
 */
@RestController
@RequestMapping("/evaFile")
public class PurEvaFileController extends BaseController
{
    @Autowired
    private IPurEvaFileService purEvaFileService;

    /**
     * 查询招标附件列表
     */
    @RequiresPermissions("purs:evaFile:list")
    @GetMapping("/list")
    public TableDataInfo list(PurEvaFile purEvaFile)
    {
        startPage();
        List<PurEvaFile> list = purEvaFileService.selectPurEvaFileList(purEvaFile);
        return getDataTable(list);
    }

    /**
     * 导出招标附件列表
     */
    @RequiresPermissions("purs:evaFile:export")
    @Log(title = "招标附件", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PurEvaFile purEvaFile)
    {
        List<PurEvaFile> list = purEvaFileService.selectPurEvaFileList(purEvaFile);
        ExcelUtil<PurEvaFile> util = new ExcelUtil<PurEvaFile>(PurEvaFile.class);
        util.exportExcel(response, list, "招标附件数据");
    }

    /**
     * 获取招标附件详细信息
     */
    @RequiresPermissions("purs:evaFile:query")
    @GetMapping(value = "/{evaCode}")
    public AjaxResult getInfo(@PathVariable("evaCode") String evaCode)
    {
        return success(purEvaFileService.selectPurEvaFileByEvaCode(evaCode));
    }

    /**
     * 新增招标附件
     */
    @RequiresPermissions("purs:evaFile:add")
    @Log(title = "招标附件", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PurEvaFile purEvaFile)
    {
        return toAjax(purEvaFileService.insertPurEvaFile(purEvaFile));
    }

    /**
     * 修改招标附件
     */
    @RequiresPermissions("purs:evaFile:edit")
    @Log(title = "招标附件", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PurEvaFile purEvaFile)
    {
        return toAjax(purEvaFileService.updatePurEvaFile(purEvaFile));
    }

    /**
     * 删除招标附件
     */
    @RequiresPermissions("purs:evaFile:remove")
    @Log(title = "招标附件", businessType = BusinessType.DELETE)
	@DeleteMapping("/{evaCodes}")
    public AjaxResult remove(@PathVariable String[] evaCodes)
    {
        return toAjax(purEvaFileService.deletePurEvaFileByEvaCodes(evaCodes));
    }




}
